package cn.dyp.com.agriculture.request;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 用户注册请求类，继承自AgricultureRequest
 * Created by lenovo on 2017/5/7.
 */

public class RegisterRequest extends AgricultureRequest{
    private static final String ACTION = "register";

    private String userName;
    private String password;

    public RegisterRequest(String userName) {
        super(userName);
    }

    protected String getActionName() {
        return ACTION;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * (non-Javadoc)
     */
    @Override
    protected String onGetJasonBody() {
        JSONObject jsonObj = new JSONObject();//生成一个json对象(可以添加不同类型的数据)：
        try {
            jsonObj.put("username", userName);// 用户名
            jsonObj.put("password", password);// 密码
            return jsonObj.toString();//toString()方法输出数值
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return super.onGetJasonBody();//jason协议时的获取body函数
    }
}
